package cn.ekuma.pos.pda.sale;

import greendroid.widget.QuickAction;
import greendroid.widget.QuickActionGrid;
import greendroid.widget.QuickActionWidget;
import greendroid.widget.QuickActionWidget.OnQuickActionClickListener;
import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import cn.ekuma.data.ui.android.BaseBeanListSelecter;
import cn.ekuma.pos.android.pos.R;

import com.openbravo.bean.sales.TicketLine;

public class TicketLines extends BaseBeanListSelecter<TicketLine>{

	QuickActionGrid actionGrid;
	TicketManager ticketManager;
	TicketLineListAdapter adapter;
	
	public TicketLines(Context context,TicketManager ticketManager,TicketLineListAdapter adapter) {
		super(context);
		// TODO Auto-generated constructor stub
		actionGrid=new QuickActionGrid(context);	
		this.ticketManager=ticketManager;
		this.adapter=adapter;
		this.setAbstractBaseBeanAdapter(adapter);
	}

	public boolean onItemLongClick(AdapterView<?> parent, View view,
			final int position, long id) {
		if(!ticketManager.isEditable())
			return false;
		actionGrid.clearAllQuickActions();
		actionGrid.addQuickAction(new QuickAction(this.getContext(),R.drawable.locationbar_erase , "删除"));
		actionGrid.addQuickAction(new QuickAction(this.getContext(),R.drawable.colorize , "属性"));
		actionGrid.addQuickAction(new QuickAction(this.getContext(),R.drawable.colorize , "口味"));
		actionGrid.setOnQuickActionClickListener(new OnQuickActionClickListener(){
			public void onQuickActionClicked(QuickActionWidget widget,
					int position1) {	
				switch(position1){
				  case 0:
					TicketLine temp=adapter.getItem(position);
					ticketManager.removeTicketLine(position);	
					break;
				  case 1:
				  case 2:
					  break;		
				}
			}
		});
		actionGrid.show(view);
		return false;
	}
}
